package com.sch.www.ele.feign.fallback;


import com.sch.www.common.base.ResultBean;
import com.sch.www.ele.entity.CareUser;
import com.sch.www.ele.feign.CareUserApi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PathVariable;


/**
 * 日志断路器实现
 *
 * @author tangyi
 * @date 2019/3/23 23:39
 */

public class CareUserApiFallbackImpl implements CareUserApi {

    private static final Logger logger = LoggerFactory.getLogger(CareUserApiFallbackImpl.class);

    private Throwable throwable;

    public Throwable getThrowable() {
        return throwable;
    }

    public void setThrowable(Throwable throwable) {
        this.throwable = throwable;
    }

    /**
     * 根据用户名获取用户详细信息
     *
     * @param accountId accountId
     * @return Account
     * @author tangyi
     * @date 2019/03/17 12:14
     */
    @Override
    public ResultBean<CareUser> getByAccountId(@PathVariable String accountId) {
        logger.error("feign查询用户信息失败:{},{}", accountId, throwable);
        ResultBean<CareUser> resultBean= ResultBean.newInstance();
        return resultBean.setHttpStatus(HttpStatus.SERVICE_UNAVAILABLE).setError().setMsg(throwable.getMessage());
    }



}
